<?php
/**用户类
 * liangxinzhao
 */
class User extends Model{
    public function __construct(){
       parent::__construct();
    }
    /*
     * 检测用户名密码是否正确
     * param username 用户名 userpwd密码
     * 返回 成功 true 失败 USER_LOGIN_ERROR
     * 
     */
     public function chkUserLogin($username,$userpwd){
        $sql = "SELECT COUNT(user_name) FROM littleoj_user WHERE user_name = '$username' AND user_pwd = '$userpwd'";
        $result = $this->getVar($sql);
        if($result == 0){
            return USER_LOGIN_ERROR;
        }else{
            return true;
        }
    }
    /*
     * 注册新用户
     * param username 用户名 userpwd密码
     * 返回 sql执行结果
     */
    public function userReg($username,$userpwd){
        $result = false;
        if(isset($username) && isset($userpwd)){
            $sql="insert into littleoj_user (user_name, user_pwd) values ('$username','$userpwd')";
            $result = parent::query($sql);
        }
        return $result;
    }
}